package com.xbongbong.pro.enums.fund.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @Description  支付方式（主要资金设置内使用）
 * @author: shian
 * @date : 2020/12/21
 */
@Getter
public enum PayMethodFundSetEnum {
    //是枚举PayMethodDistributorEnum的子集，name、alias从其获取
    //微信：weChat
    WECHAT(PayMethodDistributorEnum.WECHAT.getCode(), "enum.payMethodDistributor.name.wechat", PayMethodDistributorEnum.WECHAT.getAlias(), "web-icon-weixin", "enum.payMethodFundSet.description.wechat", "enum.payMethodFundSet.tips.wechat", "https://xbb.yuque.com/docs/share/f27004fd-b562-49e9-b4f9-80bc0a982518?#"),

    //支付宝：alipay
    ALIPAY(PayMethodDistributorEnum.ALIPAY.getCode(), "enum.payMethodDistributor.name.alipay", PayMethodDistributorEnum.ALIPAY.getAlias(), "web-icon-zhifubao", "enum.payMethodFundSet.description.alipay", "enum.payMethodFundSet.tips.alipay", ""),

    //银联：unionPay
    UNION_PAY(PayMethodDistributorEnum.UNION_PAY.getCode(), "enum.payMethodDistributor.name.union_pay", PayMethodDistributorEnum.UNION_PAY.getAlias(), "web-icon-yinlian", "enum.payMethodFundSet.description.union_pay", "enum.payMethodFundSet.tips.union_pay", ""),

    //线下打款：offline
    OFFLINE(PayMethodDistributorEnum.OFFLINE.getCode(), "enum.payMethodDistributor.name.offline", PayMethodDistributorEnum.OFFLINE.getAlias(), "web-icon-caiyouduo_zhifu-qianbaozhifu", "enum.payMethodFundSet.description.offline", "", ""),

    ;

    /**
     * 支付-标识
     */
    private String code;

    /**
     * 支付-名称
     */
    private String name;

    /**
     * 支付-别名
     */
    private String alias;

    /**
     * 支付-图标
     */
    private String icon;

    /**
     * 支付-描述
     */
    private String description;

    /**
     * 支付-提示
     */
    private String tips;

    /**
     * 支付-开通引导
     */
    private String guideUrl;

    PayMethodFundSetEnum(String code, String name, String alias, String icon, String description, String tips, String guideUrl) {
        this.code = code;
        this.name = name;
        this.alias = alias;
        this.icon = icon;
        this.description = description;
        this.tips = tips;
        this.guideUrl = guideUrl;
    }

    public static PayMethodFundSetEnum getByAlias(String alias) {
        for (PayMethodFundSetEnum payMethodEnum : values()) {
            if (Objects.equals(payMethodEnum.getAlias(),alias)) {
                return payMethodEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getDescription() {
        return I18nMessageUtil.getMessage(description);
    }

    public String getTips() {
        return I18nMessageUtil.getMessage(tips);
    }
}